extends KinematicBody2D
# 火箭公主
const speed = 200
# 攻击距离
var shecheng = 600

enum state {move,attack_enemy,attack_tower}
var current_state 

func _ready():
	current_state = state.move
	pass 

func _process(delta):
	if current_state == state.move:
		var kc = move_and_collide(Vector2(0,-1))
		var distance = self.global_position.distance_to(Vector2(291,83))
		if distance < shecheng:
			current_state = state.attack_tower
	elif current_state == state.attack_tower:
		$Timer.start()
		set_process(false)
	pass

func _on_Timer_timeout():
	var ball = load("res://obj/Huojian.tscn").instance()
	get_tree().current_scene.add_child(ball)
	ball.global_position = self.global_position
	ball.shot()
	#print_debug("攻击")
	pass # Replace with function body.
